import http from '../utils/request';
// import {GetMerCashOrderDetailRes} from './store.d.ts'

interface Pages {
	tyjPageNum : number;
	tyjPageSize : number;
}

interface defaultRes {
	code : number;
	data : string;
	msg : string;
}

interface CustomerList extends Pages {
	"keyword" ?: string,
	"sortType" ?: string | number,
	"type" ?: 0 | 1 | 2 | 3 | 4
}

interface StoreManage {
	"businessTypeList" : [],
	"open24Hours" : boolean,
	"openTimeEnd" : string,
	"openTimeStart" : string,
	"status" : '0' | '1',
	"storeId" : string
}
interface StoreCustomerOrderList extends Pages {
	"userId" : string
}

interface GetStoreGoodsList extends Pages {
	"serviceType" : string,
	"status" : string,
	keyword ?: string
}
// 商户首页
export function getStoreMainInfo() : Promise<any> {
	return http('/api/auth/mer/store/getStoreMainInfo')
}
// 商户申请详情
export function getAppleMerchant() : Promise<any> {
	return http('/api/auth/mer/info/getAppleMerchant')
}

// 商户申请
export function appleMerchant(params : AppleMerchantParams) : Promise<any> {
	return http('/api/auth/mer/info/appleMerchant', params, 'POST') as any
}
// 商户申请 修改
export function updateAppleMerchant(params : AppleMerchantParams) : Promise<DefaultRes> {
	return http('/api/auth/mer/info/updateAppleMerchant', params, 'POST') as any
}
// 门店管理页面
export function getStoreManageIndex() : Promise<any> {
	return http('/api/auth/mer/store/getStoreManageIndex')
}
// 门店客户列表
export function getStoreCustomerList(params : CustomerList) : Promise<any> {
	return http('/api/auth/mer/customer/getCustomerList', params, 'POST')
}

// 门店客户订单列表
export function getStoreCustomerOrderList(params : GetStoreCustomerOrderListParams) : Promise<GetStoreCustomerOrderListRes> {
	return http('/api/auth/mer/store/getStoreCustomerOrderList', params, 'POST') as any
}

// 门店管理修改
export function editStoreManage(params : StoreManage) : Promise<any> {
	return http('/api/auth/mer/store/editStoreManage', params, 'POST')
}
// 门店管理--商品管理列表
export function getStoreGoodsList(params : GetStoreGoodsList) : Promise<any> {
	return http('/api/auth/mer/store/goods/getStoreGoodsList', params, 'POST')
}

// 获取员工列表

interface ListMerClerk extends Pages {
	filter ?: number
}


export function listMerClerk(params : ListMerClerk) : Promise<any> {
	return http('/api/auth/mer/clerk/listMerClerk', params, 'POST')
}
// 添加员工
export function createClerk(params : {
	clerkName ?: string;
	customerAuth ?: number;
	goodsAuth ?: number;
	id ?: string;
	mobile ?: string;
	orderAuth ?: number;
	serviceAuth ?: number;
	workOrderAuth ?: number;
}) : Promise<any> {
	return http(`/api/auth/mer/clerk/createClerkV2`, params, 'POST')
}
// 编辑员工
export function updateClerk(params : {
	clerkName ?: string;
	customerAuth ?: number;
	goodsAuth ?: number;
	id ?: string;
	mobile ?: string;
	orderAuth ?: number;
	serviceAuth ?: number;
	workOrderAuth ?: number;
}) : Promise<any> {
	return http(`/api/auth/mer/clerk/updateClerk`, params, 'POST')
}


// 删除员工
export function clerkdelete(params : { id : string }) : Promise<any> {
	return http('/api/auth/mer/clerk/delete', params, 'DELETE')
}

// 经营报表-员工统计
export function getStoreManagementStaffReport(params : {
	countMonth ?: string,
	"endTime" ?: string,
	"startTime" ?: string,
	tyjPageNum ?: number,
	tyjPageSize ?: number
}) : Promise<any> {
	return http('/api/auth/mer/store/getStoreManagementStaffReport', params, 'POST')
}

// 商家提现申请
export function addMerCashOrder(params : { amount : number, cardId : string }) : Promise<any> {
	return http('/api/auth/mer/cash/addMerCashOrder', params, 'POST')
}

// 商家提现记录
export function getMerCashOrderList(params : Pages) : Promise<any> {
	return http('/api/auth/mer/cash/getMerCashOrderList', params, 'POST')
}
// 商家提现详情
export function getMerCashOrderDetail(params : { cashOrderId : string }) : Promise<GetMerCashOrderDetailRes> {
	return http('/api/auth/mer/cash/getMerCashOrderDetail', params)
}

// 查询商家系统门店收益详情
export function apiListMerGoodsOrderIncome(params : Pages) : Promise<ApiListMerGoodsOrderIncomeRes> {
	return http('/api/auth/mer/store/apiListMerGoodsOrderIncome', params, 'POST') as any
}
// 查询商家系统Vip收益详情
interface ApiListMerVipIncomeRes {
	code : number;
	msg : string;
	pageNum : number;
	pageSize : number;
	rows : {
		accountTrend : string;
		createTime : Record<string, unknown>;
		goodsName : string;
		income : number;
		mobile : string;
		userId : string;
		vipLevel : string;
		vipLevelLabel : string;
		vipOrderId : string;
	}[];
	total : number;
}

export function apiListVipOrderIncome(params : Pages) : Promise<ApiListMerVipIncomeRes> {
	return http('/api/auth/mer/store/apiListMerVipIncome', params, 'POST') as any
}


// 询商家系统门店收益详情汇总
interface ApiListMerGoodsOrderIncomeSummaryRes {
	code : number;
	data : {
		merOrderId : string;
		monthIncome : number;
		todayIncome : number;
		totalIncome : number;

		todayStoreIncome : number;
		monthStoreIncome : number;
		totalStoreIncome : number;
		todayVipIncome : number;
		monthVipIncome : number;
		totalVipIncome : number;
	};
	msg : string;
}
export function apiListMerGoodsOrderIncomeSummary() : Promise<ApiListMerGoodsOrderIncomeSummaryRes> {
	return http('/api/auth/mer/store/apiListMerGoodsOrderIncomeSummary', {}, 'POST') as any
}

// 获取商户门店业务类型[入住--管理商品]
export function getMeBusinessTypes() : Promise<GetMeBusinessTypesRes> {
	return http('/api/auth/mer/store/goods/getMeBusinessTypes') as any
}

// 获取本地商户门店业务类型[入住--管理商品]
export function getLocalMeBusinessTypes() : Promise<GetMeBusinessTypesRes> {
	return http('/api/auth/mer/store/goods/getLocalMeBusinessTypes') as any
}

// 门店管理--商品提成设置
export function editGoodsCommission(params : {
	businessType ?: string;
	commissionAmount ?: number;
	goodsId ?: string;
}) : Promise<defaultRes> {
	return http('/api/auth/mer/store/goods/editGoodsCommission', params, 'POST') as any
}